package com.linjacy.httpproject.config;

import com.linjacy.httpproject.enums.GroupEnum;
import org.springframework.stereotype.Component;

@Component
public class TableShardStrategyId implements ITableShardStrategy{

    @Override
    public String generateTableName(String tableNamePrefix, Object value) {
        //校验表名前缀不能为空
        verificationTableNamePrefix(tableNamePrefix);
        if(value.equals(GroupEnum.CHEERFUL.getGroupName())){
            return tableNamePrefix + "_" + GroupEnum.CHEERFUL.getCode();
        }else if(value.equals(GroupEnum.SAD.getGroupName())){
            return tableNamePrefix + "_" + GroupEnum.SAD.getCode();
        }else if(value.equals(GroupEnum.HAPPY.getGroupName())){
            return tableNamePrefix + "_" + GroupEnum.HAPPY.getCode();
        }
        return tableNamePrefix;
    }

}
